import request from '../utils/request'

export default {
  // 版本2
  // register (username, password, email) {
  //   return request({
  //     url: '/user/register',
  //     method: 'post',
  //     data: {
  //       email: email,
  //       username: username,
  //       password: password
  //       // formName: formName
  //     }
  //   })
  // }
  // 版本1
  register (formName) {
    return request({
      url: '/user/register',
      method: 'post',
      data: {
        email: formName.email,
        username: formName.username,
        password: formName.password
        // formName
      },
      transformRequest: [
        function (data) {
          let ret = ''
          for (const it in data) {
            ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'
          }
          return ret
        }]
    })
  }
}
